package com.ww.wwaiagent.demo.invoke;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;


/**
 * Spring AI 框架调用 AI 大模型
 * @author 15357
 * @create 2025/5/11 23:54
 */
// 取消注释即可在 SpringBoot 项目启动时执行
//@Component
public class SpringAiInvoke implements CommandLineRunner {

    @Resource
    private ChatModel dashcopeChatModel;

    @Override
    public void run(String... args) throws Exception {
        AssistantMessage assistantMessage = dashcopeChatModel.call(new Prompt("你好,我是本次的面试者汪汪"))
                .getResult()
                .getOutput();
        System.out.printf(assistantMessage.getText());
    }
}
